import pandas as pd

# 读取公司名单txt
with open('已经通过的高新产业.txt', 'r', encoding='utf-8') as f:
    company_set = set(line.strip() for line in f if line.strip())

# 读取xlsx
df = pd.read_excel('自贡企业信息.xlsx')

# 检查列名
if 'companyName' not in df.columns or 'hightech' not in df.columns:
    raise ValueError('xlsx文件中缺少companyName或hightech列')

# 赋值hightech列
df['hightech'] = df['companyName'].apply(lambda x: 1 if x in company_set else 0)

# 保存结果
df.to_excel('自贡企业信息output.xlsx', index=False)